package com.cskaoyan.jdbc;

import com.cskaoyan.jdbc.util.JDBCUtils;
import com.mysql.jdbc.Driver;

import java.sql.*;

/**
 * 创建日期: 2022/06/01 11:24
 *
 * @author ciggar
 */
public class QueryDemo2 {


    public static void main(String[] args) throws SQLException {

        Connection connection = JDBCUtils.getConnection();

        Statement statement = connection.createStatement();

        ResultSet resultSet = statement.executeQuery("select * from city");

        while (resultSet.next()) {

            int id = resultSet.getInt("id");

            String name = resultSet.getString("name");

            int pid = resultSet.getInt("pid");

            System.out.println("id:" + id + ", name:" + name + ", pid:" + pid);
        }

        JDBCUtils.close(resultSet,statement,connection);

    }
}
